package cn.signalpha.modules.com.controller.seller;

import cn.signalpha.common.constant.AppConstant;
import cn.signalpha.core.boot.ctrl.BaseController;
import cn.signalpha.core.mp.support.Condition;
import cn.signalpha.core.mp.support.Query;
import cn.signalpha.core.tool.api.R;
import cn.signalpha.modules.com.entity.UserLevel;
import cn.signalpha.modules.com.service.UserLevelService;
import cn.signalpha.modules.com.service.UserService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;

import java.util.List;
import java.util.Map;

/**
 * 控制器
 *
 * @author signalpha
 */
@RestController
@AllArgsConstructor
@RequestMapping(AppConstant.APPLICATION_USER_NAME + "/sys-seller/user/level")
@Api(value = "用户等级", tags = "用户等级")
public class SpiUserLevelController extends BaseController {

	private final UserService userService;
	private final UserLevelService userLevelService;

	@GetMapping("/page")
	@ApiOperation(value = "分页", notes = "")
	public R<IPage<UserLevel>> page(@ApiIgnore @RequestParam Map<String, Object> params, Query query) {
		QueryWrapper<UserLevel> queryWrapper = userLevelService.selectUserLevelWrapper(params);
		return R.data(userLevelService.page(Condition.getPage(query), queryWrapper));
	}

	@GetMapping("/list")
	@ApiOperation(value = "列表", notes = "")
	public R<List<UserLevel>> list(@ApiIgnore @RequestParam Map<String, Object> params) {
		return R.data(userLevelService.list(userLevelService.selectUserLevelWrapper(params)));
	}

	@GetMapping("/info")
	@ApiOperation(value = "详情", notes = "传入id")
	public R<UserLevel> info(@ApiParam(value = "主键", required = true) @RequestParam Long id) {
		return R.data(userLevelService.getById(id));
	}

}
